package test.regular

import java.util.regex.Matcher
import java.util.regex.Pattern

class RegularTestMain {
    companion object{
        /**
         * 正则表达式字符串替换
         * @param content 字符串
         * @param pattern 正则表达式
         * @param newString 新的替换字符串
         * @return 返回替换后的字符串
         */
        fun regReplace(content: String?, pattern: String?, newString: String?): String? {
            val p: Pattern = Pattern.compile(pattern)
            val m: Matcher = p.matcher(content)
            return m.replaceAll(newString)
        }
    }
}

fun main() {
//    val result = RegularTestMain.regReplace("666", null, "233")
    val result = RegularTestMain.regReplace("666", "", "233")

    println("result = $result")
}